package com.yoga.manager.beanUtil;

import com.yoga.common.bo.YogaShopBO;
import com.yoga.dao.domain.YogaShopDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类YogaShopBeanUtil.java的实现描述：工具类
 * 
 * @Author hdx
 * @Date 2020年09月28日
 */
public class YogaShopBeanUtil {

    private YogaShopBeanUtil(){
    }

    public static YogaShopDO yogaShopBOToDO(YogaShopBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        YogaShopDO targetObj = new YogaShopDO();
        targetObj.setId(srcObj.getYogaShopId());//id
        targetObj.setYogaAdminId(srcObj.getYogaAdminId());//yogaAdminId
        targetObj.setShopName(srcObj.getShopName());//店名称
        targetObj.setManagerName(srcObj.getManagerName());//店长名称
        targetObj.setManagerPhone(srcObj.getManagerPhone());//店长电话
        targetObj.setShopAddress(srcObj.getShopAddress());//店铺地址
        targetObj.setShopProfile(srcObj.getShopProfile());//店铺介绍
        targetObj.setShopImg(srcObj.getShopImg());//店铺所属账号
        targetObj.setDeleteMark(srcObj.getDeleteMark());//deleteMark
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        return targetObj;
    }

    public static YogaShopBO yogaShopDOToBO(YogaShopDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        YogaShopBO targetObj = new YogaShopBO();
        targetObj.setYogaShopId(srcObj.getId());//id
        targetObj.setYogaAdminId(srcObj.getYogaAdminId());//yogaAdminId
        targetObj.setShopName(srcObj.getShopName());//店名称
        targetObj.setManagerName(srcObj.getManagerName());//店长名称
        targetObj.setManagerPhone(srcObj.getManagerPhone());//店长电话
        targetObj.setShopAddress(srcObj.getShopAddress());//店铺地址
        targetObj.setShopProfile(srcObj.getShopProfile());//店铺介绍
        targetObj.setShopImg(srcObj.getShopImg());//店铺所属账号
        targetObj.setDeleteMark(srcObj.getDeleteMark());//deleteMark
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        return targetObj;
    }

    public static List<YogaShopBO> doList2BOList(List<YogaShopDO> doList) {
        List<YogaShopBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        doList.stream().forEach(yogaShopDO -> boList.add(YogaShopBeanUtil.yogaShopDOToBO(yogaShopDO)));

        return boList;
    }
}